package com.repast.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.repast.common.ServerResponse;
import com.repast.service.IFoodsService;

@Controller
@RequestMapping("/foods/")
public class FoodsController {
	
	@Autowired
	private IFoodsService foodsService;

	//查询所有的菜品
	@RequestMapping("list.do")
	@ResponseBody
	public ServerResponse selectfoodsList(
			@RequestParam(value = "pageNum", defaultValue = "1")Integer pageNum,
			@RequestParam(value = "pageSize", defaultValue = "6")Integer pageSize){
		ServerResponse response = foodsService.selectFoodsList(pageNum,pageSize);
		return response;
	}
	
	// 根据菜品类型id,查询当前所有的菜品
		@RequestMapping(value="listById.do")
		@ResponseBody
		public ServerResponse selectFoodsListById(@RequestParam(value = "pageNum", defaultValue = "1")Integer pageNum,
				@RequestParam(value = "pageSize", defaultValue = "6")Integer pageSize,
				Integer foodsTypeId){
			return foodsService.selectFoodsListByFoodsTypeId(pageNum, pageSize, foodsTypeId);
		}
}
